var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, r) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var r in t)
              Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
          })(t, r);
      };
      return function (t, r) {
        function a() {
          this.constructor = t;
        }
        if ("function" != typeof r && null !== r)
          throw new TypeError(
            "Class extends value " + String(r) + " is not a constructor or null"
          );
        e(t, r),
          (t.prototype =
            null === r
              ? Object.create(r)
              : ((a.prototype = r.prototype), new a()));
      };
    })(),
  AXTreasureView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.onLoadTreasureBaoWuDataListFn = {
          caller: t,
          code: 1120,
          method: function (e) {
            if (0 == e.code) {
              t.listArr = e.list;
              var r;
              t.dataSource = [];
              for (var a = 0; a < t.listArr.length; a++)
                (r = {
                  label_treasure_baowuname: { text: t.listArr[a].name },
                  btn_treasureGouMai: { label: t.listArr[a].price + "金" },
                  item_good_name: { text: t.listArr[a].name },
                  item_good_pic: { skin: t.listArr[a].pic },
                  item_goods_nums: { text: t.listArr[a].price },
                  pic: t.listArr[a].pic,
                }),
                  t.dataSource.push(r);
              t.list_baoku_list.dataSource = t.dataSource;
            }
          },
        }),
        (t.onLoadTreasureJingYanShuDataListFn = {
          caller: t,
          code: 1199,
          method: function (e) {
            if (0 == e.code) {
              t.listArr = e.list;
              var r;
              t.dataSource = [];
              for (var a = 0; a < t.listArr.length; a++)
                (r = {
                  label_treasure_baowuname: { text: t.listArr[a].name },
                  btn_treasureGouMai: { label: t.listArr[a].price + "金" },
                  item_good_name: { text: t.listArr[a].name },
                  item_good_pic: { skin: t.listArr[a].pic },
                  item_goods_nums: { text: t.listArr[a].price },
                  pic: t.listArr[a].pic,
                }),
                  t.dataSource.push(r);
              t.list_baoku_list.dataSource = t.dataSource;
            }
          },
        }),
        t.btn_treasureCancle.on(Laya.Event.CLICK, t, t.onTreasureClose),
        t.tab_treasureItem.on(Laya.Event.CLICK, t, t.onDidClickTabItemFn),
        WebSocketService.addListener(t.onLoadTreasureBaoWuDataListFn),
        WebSocketService.addListener(t.onLoadTreasureJingYanShuDataListFn),
        WebSocketService.addListener({
          caller: t,
          code: 1451,
          method: t.onLoadMySelfMoney,
        }),
        (t.list_baoku_list.vScrollBarSkin = ""),
        (t.list_baoku_list.selectEnable = !0),
        t.list_baoku_list.on(
          Laya.Event.CLICK,
          t,
          t.onDidClickTreasureSelectedFn
        ),
        (t.list_baoku_list.renderHandler = new Laya.Handler(
          t,
          t.onRenderHandlerItem
        )),
        t
      );
    }
    return (
      __extends(t, e),
      (t.openView = function () {
        return (
          null == this.treasureVC && (this.treasureVC = new t()),
          (this.treasureVC.tab_treasureItem.selectedIndex = 0),
          (this.treasureVC.list_treasureBaoWu.visible = !1),
          WebSocketService.send({ c: 1120, d: { pageNum: 0 } }),
          WebSocketService.send({ c: 1451, d: { pageNum: 0 } }),
          this.treasureVC
        );
      }),
      (t.prototype.onLoadMySelfMoney = function (e) {
        (this.label_treasure_gold.visible = !0),
          (this.label_treasure_gold.text = "金 ：" + e.data.gold);
      }),
      (t.prototype.onRenderHandlerItem = function (e, t) {
        this.listArr.length > 0 && (this.list_treasureBaoWu.visible = !0);
        var r = e.getChildByName("item_goods_pic");
        e.dataSource.pic
          ? (r.skin = "comp/goods/" + e.dataSource.pic)
          : (r.skin = "comp/goods/none.png");
      }),
      (t.prototype.onDidClickTabItemFn = function (e) {
        (this.list_treasureBaoWu.visible = !1),
          "item0" == e.target.name
            ? WebSocketService.send({ c: 1120, d: { pageNum: 0 } })
            : "item1" == e.target.name
            ? WebSocketService.send({ c: 1199, d: { pageNum: 0 } })
            : "item2" == e.target.name &&
              (this.list_treasureBaoWu.dataSource = []);
      }),
      (t.prototype.onDidClickTreasureSelectedFn = function (e) {
        if ("" != e.target.name)
          if (0 == this.tab_treasureItem.selectedIndex) {
            if (this.list_baoku_list.selectedIndex >= this.listArr.length)
              return;
            "btn_treasureGouMai" == e.target.name
              ? BuyMedicalView.showTreasure(
                  this.listArr[this.list_baoku_list.selectedIndex]
                )
              : e.target.name &&
                AXTreasureDetailDialog.showTreasureDialog(
                  this.listArr[this.list_baoku_list.selectedIndex]
                );
          } else
            1 == this.tab_treasureItem.selectedIndex &&
              BuyMedicalView.showTreasure(
                this.listArr[this.list_baoku_list.selectedIndex]
              );
      }),
      (t.prototype.onTreasureDidClickFn = function (e) {
        if (
          "" != e.target.name &&
          0 == this.tab_treasureItem.selectedIndex &&
          "btn_treasureGouMai" == e.target.name
        ) {
          var t = this.listArr[this.tab_treasureItem.selectedIndex].name,
            r = this.listArr[this.tab_treasureItem.selectedIndex].price,
            a = this.listArr[this.tab_treasureItem.selectedIndex].id;
          BuyMedicalView.showMedical(t, r, a);
        }
      }),
      (t.prototype.onTreasureChongZhiDidClickFn = function () {
        var e = PuranceView.openView();
        e.pos(0, 40), Laya.stage.addChild(e);
      }),
      (t.prototype.onTreasureClose = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.TabBarItemController.AXTreasureViewUI);
